import React, { Component, createRef } from "react";

export default class UNControlled extends Component {
  constructor() {
    super();
    this.inputRef = createRef();
  }
  render() {
    return (
      <div>
        <h2>非受控组件</h2>
        <input type="text" ref="inputRef" />
        <br />
        <input type="text" ref={this.inputRef} />
        <br />
        <input type="text" ref={(el) => (this.method = el)} />
        <button onClick={(e) => this.handleGetValue(e)}>确定</button>
      </div>
    );
  }

  handleGetValue() {
    console.log(this.refs.inputRef.value);
    console.log(this.inputRef.current.value);
    console.log(this.method.value);
  }
}
